//
//  NSObject+Tools.m
//  Runner
//
//  Created by Danny Duan on 2019/12/22.
//  Copyright © 2019 The Chromium Authors. All rights reserved.
//

#import "NSObject+Tools.h"

@implementation NSObject (Tools)
+ (id)objectFromJsonString:(NSString *)jsonString {
    if (jsonString == nil) {
        return nil;
    }
    
    NSData *jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
    NSError *err;
    id result = [NSJSONSerialization JSONObjectWithData:jsonData
                                                options:NSJSONReadingMutableContainers
                                                  error:&err];
    if(err) {
        NSLog(@"json解析失败：%@",err);
        return nil;
    }
    return result;
}
@end
